#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
using namespace std;
inline int read(){
    int u=0,v=1;
    char ch=getchar();
    while(!isdigit(ch)){
        if(ch=='-') v=-1;
        ch=getchar();
    }
    while(isdigit(ch)){
        u=(u<<1)+(u<<3)+ch-'0';
        ch=getchar();
    }
    return u*v;
}
void print(int x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
const int N=1e5+10;
int T;
int n,m,L,V,ans;
struct che{
    int d,v,a;
};
che c[N];
int p[N];
struct node{
    int st,ed;
};
node lis[N];
inline bool cmp(node x,node y){
    return x.ed<y.ed;
}
inline int fd1(long double x){//lower_bound
    int tot=-1,l=1,r=m;
    while(l<=r){
        int mid=(l+r)>>1;
        if(p[mid]>=x){
            tot=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    return tot;
}
inline int fd2(long double x){//upper_bound
    int tot=-1,l=1,r=m;
    while(l<=r){
        int mid=(l+r)>>1;
        if(p[mid]>x){
            tot=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    return tot;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--){
        n=read(),m=read(),L=read(),V=read();
        for(int i=1;i<=n;i++) c[i].d=read(),c[i].v=read(),c[i].a=read();
        for(int i=1;i<=m;i++) p[i]=read();
        stable_sort(p+1,p+1+m);//sort sensors
        L=min(L,p[m]);
        ans=0;
        for(int i=1;i<=n;i++){
            int pos=fd1(c[i].d);//first known sensor
            long double v0=c[i].v,a=c[i].a,v1=V;
            if(pos==-1) continue;//no sensors
            if(v0<=V&&a<=0) continue;//speed too low

            if(v0>v1&&a==0){
                ans++;
                lis[ans].st=pos;
                lis[ans].ed=m;
                continue;
            }
            long double dx=((v1*v1)-(v0*v0))/(2*a);
            if(v0>v1&&a<=0){//speed high,speed down
                int ed=fd1(dx+c[i].d);//first OK station
                if(ed==pos) continue;
                if(ed==-1) ed=m;
                else ed--;
                ans++;
                lis[ans].st=pos;
                lis[ans].ed=ed;
                //cout<<"a<0 "<<i<<" "<<dx<<" "<<pos<<" "<<ed<<endl;
            }
            else if(a>0){//speed up
                if(dx+c[i].d>=L) continue;
                if(v0>v1) lis[++ans].st=pos;
                else if(v0==v1){
                    if(pos==m) continue;
                    lis[++ans].st=pos+1;
                }
                else {
                    int ed=fd2(dx+c[i].d);
                    if(ed==-1) continue;
                    lis[++ans].st=ed;
                }
                lis[ans].ed=m;
            }
        }
        stable_sort(lis+1,lis+1+ans,cmp);
        // cout<<"------LIS------\n";
        // for(int i=1;i<=ans;i++){
        //     cout<<lis[i].st<<" "<<lis[i].ed<<endl;
        // }
        // cout<<"---------------\n";
        int lod=0;
        if(ans>0){
            int las=lis[1].ed;
            lod=1;
            for(int i=2;i<=ans;i++){
                if(lis[i].ed<las||lis[i].st>las) lod++,las=lis[i].ed;
            }
        }
        //cout<<"LOD "<<lod<<endl;
        print(ans);
        putchar(' ');
        print(m-lod);
        putchar('\n');
    }
    return 0;
}